#include <crdebug.h>
#include <crpool.h>

class a
{
public:
	a(){TRACE(_T("a() called\n"));}
	~a(){TRACE(_T("~a() called\n"));}
};

int _tmain(int argc, _TCHAR* argv[])
{
	{
		cr::objpool<cr::simple_wrapper_t<a>> pl1;
		pl1.init(10);
		pl1.release(pl1.lease());
		//pl1.lease();
		pl1.clear();
	}
	{
		cr::objpool<cr::object_wrapper_t<a>> pl2;
		pl2.init(10);
		pl2.release(pl2.lease());
		//pl2.lease();
		pl2.clear();
	}
	{
		cr::mempool<16> pl3;
		pl3.init(10);
		pl3.release(pl3.lease());
		//pl3.lease();
		pl3.clear();
	}
	{
		cr::idpool<10, char*, int> pl4;
		char* data = "hello";
		int nid = pl4.push(data);
		pl4.pushat(100, data);

		char* res;
		ASSERT(pl4.lookup(nid, res));
		ASSERT(res == data);
		ASSERT(pl4.pop(nid, res));
		ASSERT(res == data);
		//then <nid,data> is disappear
		ASSERT(!pl4.pop(nid, res));
		ASSERT(pl4.lookup(100, res));
	}

	return 0;
}

